#include<stdio.h>

         
    int insert()
    {
    int list[10];
    int back,i,N,loc,Val;
    printf("\n Enter the value to be inserted and its location:");
    scanf("%d%d",&Val,&loc);
    if (loc<N)
    {
    back=N+1;
    while(back>loc)
    {
    list[back]=list[back-1];
    back--;
    }
    list[loc]=Val;
    N++;
    printf("The new list is...");
    for(i=0;i<N;i++)
    printf("%d",list[i]);
    }
    else
    printf("\n The insertion not allowed");
    }

int sort()

{
    int list[10],small, pos,N, i,j,temp;
    printf ("\n Enter the size of the list :");
    scanf ("%d", & N);
    printf ("\n Enter the list : ");
    for ( i = 0; i < N; i++)
    {
        printf ("\n Enter Number :");
        scanf ("%d", &list[i]);

    }
    
    for (i = 0;i < N - 1 ; i++)
    {
        small = list[i];
        pos = i;
   
        for ( j = i+1; j<N; j++)
        {
            if (small > list [j])
                {
                    small = list [j];
                    pos = j;

                }

        }
        temp = list [i];
        list[i]= list [pos];
        list[pos]= temp;
   
    }
    printf ("The Sorted list...");
        for ( i = 0; i < N; i++)
        printf ( "%d", list[i]);

}

int append()

{   
    int i,list[10],N,Val;

    printf("Enter the size of the array");
    scanf("%d",&N);
   
    printf("Enter the array elements:");
    for (i=0;i<N;i++)
    {    printf("Enter the element %d of  the array:",i+1);
            scanf("%d",&list[i]);
        }
   
    printf("Enter the value to be inserted:");
    scanf("%d",&Val);

        list[N+1]=Val;
        N++;

    printf("The new list is...");
        for(i=0;i<N;i++)
        printf("%d",list[i]);
}

int index()

{    int i,list[10],N,Val;

    printf("Enter the size of the array");
    scanf("%d",&N);
   
    printf("Enter the array elements:");
    for (i=0;i<N;i++)
    {    printf("Enter the element %d of  the array:",i+1);
            scanf("%d",&list[i]);
        }
   
    printf("Enter the value whose index is to find :");
    scanf("%d",&Val);
   
    for (i=0;i<N;i++)
    {    if(list[i]==Val)
        {    printf("The value is found at %d position",i);
            break;
        }
        else
            printf("The value %d is not found!!!",Val);
    }
}

int remove()
{    
	int i,j,N,Val;
	int list[10];
    printf("Enter the size of the array");
    scanf("%d",&N);
   
    printf("Enter the array elements:");
    for (i=0;i<N;i++)
    {    printf("Enter the element %d of  the array:",i+1);
            scanf("%d",&list[i]);
        }
   
    printf("Enter the value to be removed:");
    scanf("%d",&Val);
    for(i=0;i<N;i++)
    {    if (list[i]==Val)
        {    for(j=i;j<N-1;j++)
            list[j]=list[j+1];
            list[N-1]="\0";
        }
        else
            printf("The number you entered is not in list!!!");
    }           
}


void reverse(int inver_a[],int j)

{ 
    int a[N],c[j],d[j],i,j,temp;

       printf("Enter the list \n");
       for(j=0;j<i;j++)
          scanf("%d",&c[j]);

       printf("The list is \n");
       for(j=0;j<i;j++)
          printf("%d ",d[j]);
       printf("\n");   
   
  
       j--;

       for(i=0;i<(j/2);i++)
       {
              temp=inver_a[i];
              inver_a[i]=inver_a[j];
              inver_a[j]=temp;
              j--;
       }
}

void count(int a[],int num)

{
    //int a[10] ;
        int count = 0;
   int i,j;
    printf("Enter the list \n");
       for(j=0;j<i;j++)
          scanf("%d",&a[j]);
    
        for (int i = 0; i < 10; i++)
    {
            if (a[i] == 5)
        {
                   count++;
                }
          }
      printf("the Number %d is occuring %d times",num,count);
}

void extend(int a[],int len)

{
    int a[],b[],len,len1,i,j;

printf("Enter the size of your array");
scanf("%d",&len);


printf("Enter the array elements")

for(i=0;i<len;i++)
{
    scanf("%d",&a[i]);
}

printf("enter the number of elements you want to add to the list");
scanf("%d",len1);

printf("Enter the values one by one");

for (j=0;j<len1;j++)

{
    scanf("%d",&b[j]);
}

int len2=len+len1;

for(k=0;k<len2;k++)
{
    for(i=0;i<len;i++)
        {    while(k==i)
                c[k]=a[i];
        }   
}
for(j=0;j<len1;j++)
{
    c[k+1]=b[j];

}
   
printf("The new list is \n");
       for(k=0;k<len2;k++)
          printf("%d ",c[k]);
       printf("\n");   
- Hide quoted text -

    main()
    {
    int c;

    printf("The menu for array operations is as follows :");
    printf("1.Append:");
    printf("2.Extend:");
    printf("3.Insert:");
    printf("4.Remove:");
    printf("5.Pop:");
    printf("6.Index:");
    printf("7.Count:");
    printf("8.Sort:");
    printf("9.Reverse:");

    printf("Enter your choice(1-9)");
    scanf("%d",&c);
    switch(c)
    {    case(1):append();
            break;
        case(2):extend();
            break;
        case(3):insert();
            break;
        case(4):remove();
            break;
        case(5):pop();
            break;
        case(6):index();
            break;
        case(7):count();
            break;
        case(8):sort();
            break;
        case(9):reverse();
            break;

        default:printf("Please enter your choice again(1-6),,,!!!,,,,INVALID CHOICE!!!!!!:");
    }
 }

